$(function(){
  $.loadmore.get(getData, {scroll: true});
  var summary_show = true,pay_show = true;
  var tell_li = $('.tell_content ul').css('height');//小贴士有几条
  var tell_show = true;//小贴士查看更多是否可点
  var summary_content = $('.summary_content').html().replace(/(^\s+)|(\s+$)/g,"");
  if(summary_content.length > 78){
  	$('.summary_more').css({'display':'block'});
  	var old_str = summary_content.toString().substr(0,78)+"...";
  	$('.summary_content').html(old_str);
  }else{
  	$('.summary_more').css({'display':'none'});
  }
  
  $('#summary_wrap').find('.summary_more').click(function(){
  	$('.summary_more').find('i').css({'background-position':'0 100%'});
  	if(summary_show){
  		$('.summary_content').html(summary_content);
  		summary_show = false;
  		$('.summary_more').find('i').css({'background-image':'url(../../../images/common/see_now.png)'});
  		$('.summary_more a span').html('收起内容');
  	}else{
  		$('.summary_content').html(old_str);
  		summary_show = true;
  		$('.summary_more').find('i').css({'background-image':'url(../../../images/common/see_more.png)'});
  		$('.summary_more a span').html('查看更多');
  	}
  })
  var aLi = $('#pay_wrap').find('ul').find('li');
  if(aLi.length > 3){
  	$('.pay_more a').css({'display':'block'});
  	$('#pay_wrap ul').css('height','4.46rem')
  }else{
  	$('.pay_more a').css({'display':'none'});
  }
  $('#pay_wrap').find('.pay_more').click(function(){
  	if(pay_show){
  		$('#pay_wrap ul').css('height','auto');
  		pay_show = false;
  		$('.pay_more').find('i').css({'background-image':'url(../../../images/common/see_now.png)'});
  		$('.pay_more a span').html('收起内容');
  	}else{
  		$('#pay_wrap ul').css('height','4.46rem');
  		pay_show = true;
  		$('.pay_more').find('i').css({'background-image':'url(../../../images/common/see_more.png)'});
  		$('.pay_more a span').html('查看更多');
  	}
  })
 if( parseInt(tell_li) >= 450){
 	$('.tell_more').css('display','block');
 }else{
 	$('.tell_more').css('display','none');
 }
  $('.tell_more').on('click',function(){
  	if(tell_show){
  		$('.tell_content ul').css('max-height','111rem');
  		tell_show = false;
  		$('.tell_more a span').html('收起内容');
  		$('.tell_more a').find('i').css({'background-image':'url(../../../images/common/see_now.png)'});
  	}else{
  		$('.tell_content ul').css('max-height','4.5rem');
  		tell_show = true;
  		$('.tell_more a span').html('查看更多');
  		$('.tell_more a').find('i').css({'background-image':'url(../../../images/common/see_more.png)'});
  	}
  })
})
window.onload = function(){
	window.onscroll();
}
/* 加载更多 */
function getData(config){ 
	config.isAjax = true;
	$.ajax({
		type : "GET",
		dataType : "json",
		url : "../../../json/blog.json",
		data : {},
		success: function(reponse){
			console.log(21);
			config.isAjax = false;
			//to do something....
			$("#evalute_wrap").append("<div class='click_button'>2121</div>");
			$(".clickmore").html('加载更多');
			/******************隐藏more*************************/
			/*if ( (offset + size) >= sum){
				$(".clickmore").hide();
				//停止滚动加载请求
				config.isEnd = true; 
			}else{
				$(".clickmore").show();
			}*/
		},
		error: function(xhr, type){
			console.log('Ajax error!');
		}
	});
}